#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include <GL/glut.h>




void init()
{
  /* set clear color to black */
  glClearColor (0.0, 0.0, 0.0, 0.0);
  
  /* set fill color to white */
  glColor3f(1.0, 1.0, 1.0);
  
  /* set up standard orthogonal view with clipping */
  /* box as cube of side 2 centered at origin */
  /* This is default view and these statement could be removed */
}



GLvoid display(GLvoid){
  glBegin(GL_TRIANGLES);
  
  glVertex2f(-0.8, 0.8);
  
  glVertex2f(0.8, 0.8);
  
  glVertex2f(0.0, -0.8);
  
  glEnd();
  glFlush();
}


/**
   Kalles når størrelsen på skjermen endres
**/
void endre_skjerm(int w, int h)
{
  glViewport(0,0,w,h);
  glLoadIdentity ();
  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
  glClear(true);
  display();
}


int main(int argc, char** argv) {
  glutInit(&argc,argv);
  glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  glutInitWindowSize(500, 500);
  glutInitWindowPosition(0,0);
  glutCreateWindow("simple");
  glutDisplayFunc(display);
  glutReshapeFunc(endre_skjerm);
  init();
  glutMainLoop();
  return 0;
}

